package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.DateValueEntity;
import cn.limc.ohoscharts.entity.LineEntity;
import cn.limc.ohoscharts.event.IZoomable;
import cn.limc.ohoscharts.view.SlipLineChart;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

import java.util.ArrayList;
import java.util.List;

public class SlipLineChartAbility extends BaseAbility {

  SlipLineChart sliplinechart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_ability_slip_line_chart);

    initSlipLineChart();
  }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.slip_line_chart, menu);
//        return true;
//    }

  private void initSlipLineChart() {
    this.sliplinechart = (SlipLineChart) findComponentById(ResourceTable.Id_sliplinechart);
    List<LineEntity<DateValueEntity>> lines = new ArrayList<LineEntity<DateValueEntity>>();

    // 计算5日均线
    LineEntity<DateValueEntity> MA5 = new LineEntity<DateValueEntity>();
    MA5.setTitle("HIGH");
    MA5.setLineColor(Color.WHITE.getValue());
    MA5.setLineData(dv1);
    lines.add(MA5);

    // 计算10日均线
    LineEntity<DateValueEntity> MA10 = new LineEntity<DateValueEntity>();
    MA10.setTitle("LOW");
    MA10.setLineColor(Color.RED.getValue());
    MA10.setLineData(dv2);
    lines.add(MA10);

    sliplinechart.setAxisXColor(Color.LTGRAY.getValue());
    sliplinechart.setAxisYColor(Color.LTGRAY.getValue());
    sliplinechart.setBorderColor(Color.LTGRAY.getValue());
    sliplinechart.setLongitudeFontSize(14);
    sliplinechart.setLongitudeFontColor(Color.WHITE.getValue());
    sliplinechart.setLatitudeColor(Color.GRAY.getValue());
    sliplinechart.setLatitudeFontColor(Color.WHITE.getValue());
    sliplinechart.setLongitudeColor(Color.GRAY.getValue());
    sliplinechart.setMaxValue(1300);
    sliplinechart.setMinValue(700);
    sliplinechart.setDisplayFrom(10);
    sliplinechart.setDisplayNumber(30);
    sliplinechart.setMinDisplayNumber(5);
    sliplinechart.setZoomBaseLine(IZoomable.ZOOM_BASE_LINE_CENTER);
    sliplinechart.setDisplayLongitudeTitle(true);
    sliplinechart.setDisplayLatitudeTitle(true);
    sliplinechart.setDisplayLatitude(true);
    sliplinechart.setDisplayLongitude(true);
    sliplinechart.setDataQuadrantPaddingTop(5);
    sliplinechart.setDataQuadrantPaddingBottom(5);
    sliplinechart.setDataQuadrantPaddingLeft(5);
    sliplinechart.setDataQuadrantPaddingRight(5);
    // sliplinechart.setAxisYTitleQuadrantWidth(50);
    // sliplinechart.setAxisXTitleQuadrantHeight(20);
    sliplinechart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    sliplinechart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

    sliplinechart.setLinesData(lines);
  }

}
